home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / SCANF.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  679 b   |  19 lines

  1. /* scanf.c --- p 462 */
  2. #include <stdio.h>
  3. #include <math.h>
  4. main()
  5. {
  6.     int num_months;
  7.     double interest_rate, principal, final_amount;
  8.                 /* Ask user to enter all necessary amounts */
  9.     printf("Enter amount of principal, annual interest rate:");
  10.     scanf(" %lf %lf", &principal, &interest_rate);
  11.     printf("Enter number of months before deposit matures:");
  12.     scanf(" %d", &num_months);
  13.             /* Compute amount at maturity and print value */
  14.     final_amount = principal * pow((1.0 + interest_rate/12.0/100.0),
  15.                     (double)num_months);
  16.         printf("$%.2f @%.2f%% annual rate yields $%.2f "
  17.             "after %d months\n", principal, interest_rate,
  18.                         final_amount, num_months);
  19. }